﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Com.CMS263.Util;
using Com.CMS263.PO;
using Com.CMS263.BLL;
using System.IO;

namespace Com.CMS263.Web.manage.VoteManage
{
    public partial class vote_option_edit : System.Web.UI.Page
    {
        VoteOptionBLL pbll = new VoteOptionBLL();
        public VoteOption ab = new VoteOption();
        public int tid = 0;
        public VoteTopic vt = new VoteTopic();
        VoteTopicBLL vtbll = new VoteTopicBLL();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {

                BindData();
            }
        }
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string title = StringUtil.checkStr(Request["txtTitle"]);


            string sortid = StringUtil.checkStr(Request["txtSortId"]);


            int id = Convert.ToInt32(Request["id"]);
            if (id <= 0)
            {
                StringUtil.Alert("抱歉，没有找到相关数据", "vote_list.aspx");
            }
            VoteOption prod = new VoteOption();
            prod = (VoteOption)pbll.FindModelById("VoteOption", id);

            prod.SortId = Convert.ToInt32(sortid);
            prod.OptionValue = title; 
            pbll.entity = prod;
            if (pbll.UpDate())
            {
                StringUtil.Alert("修改成功", "vote_option_list.aspx?tid=" + tid);
            }


        }
        public void BindData()
        {
            int id = Convert.ToInt32(Request["id"]);
            if (id <= 0)
            {
                StringUtil.Alert("抱歉，没有找到相关数据", "vote_list.aspx");
            }

            ab = (VoteOption)pbll.FindModelById("VoteOption", id);
            tid = Convert.ToInt32(Request["tid"]);
            if (tid <= 0)
            {
                StringUtil.Alert("抱歉,没有找到相关数据", "vote_list.aspx");
            }
            vt = (VoteTopic)vtbll.FindModelById("VoteTopic", tid);
        }
    }
}
